


import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.util.Calendar;

/**
 * Top panel with add event and filter button. Also displays current month and
 * year.
 */
public class TopMenuPanel extends ObservingJPanel {
    
    protected JLabel month;
    protected JButton filter;
    protected JButton addEvent;
    
    protected CalendarController controller;
    
    public TopMenuPanel(CalendarController controller) {
        
        // Set looks of panel
        this.setBackground(new Color(228,234,239));
        this.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, new Color(64,75,84)));
        this.setLayout(new BorderLayout());
        this.setPreferredSize(new Dimension(100, 40));
        
        // Set controller
        this.controller = controller;
	
        // Add and configure components
    	Calendar today = Calendar.getInstance();
        month = new JLabel(controller.months[today.get(Calendar.MONTH)] + " " + today.get(Calendar.YEAR));
        month.setHorizontalAlignment(SwingConstants.CENTER);
        // Create filter and add event buttons
        filter = new JButton ("Filter");
        filter.addActionListener(controller.createShowFilterListener());
        addEvent = new JButton ("+");
        addEvent.addActionListener(controller.createAddEventListener());
        
        addEvent.setFont(new Font("Verdana", Font.PLAIN, 11));
        filter.setFont(new Font("Verdana", Font.PLAIN, 11));
        filter.setPreferredSize(new Dimension(62, 20));
        addEvent.setPreferredSize(new Dimension(62, 20));
        
        // Add components to panel
        this.add(filter, BorderLayout.WEST);
        this.add(month, BorderLayout.CENTER);
        this.add(addEvent, BorderLayout.EAST);
    }

    public void setTitle(java.lang.String s) {
        this.month.setText(s);
    }
    
    @Override
    public void update() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
